package com.wlstock.funi.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StrUtils {
	public static boolean isNullOrEmpty(String str){
		return str==null || "".equals(str);
	}
	
	
	public static String parseResponse(String response) {
		String temp1 = response.replaceAll("\\\\r\\\\n", "").replace("\\\"", "\"").replace("\"[", "[").replace("]\"", "]");
		temp1 = temp1.trim();
		temp1 = temp1.replaceAll(" ", "");
		return temp1;
	}
	
	/**
	 * 解析益盟仓位
	 * @param response
	 * @return
	 */
	public static String parseYICWResponse(String response){
		if (response!=null) {
			Pattern compile = Pattern.compile("<span class=\"red font35 font_arial\">(.)*</span>");
			Matcher matcher = compile.matcher(response);
			String matResult = "";
			while(matcher.find()){
				matResult = response.substring(matcher.start(), matcher.end());
			}
			String cw = "";
			Pattern cwCompile = Pattern.compile("[0-9]*%");
			Matcher matcher2 = cwCompile.matcher(matResult);
			while(matcher2.find()){
				cw =  matResult.substring(matcher2.start(),matcher2.end());
			}
			return cw;
		}
		return null;
	}
	
	
	 public static String replaceBlank(String str) {
		  String dest = "";
		  if (str!=null) {
		   Pattern p = Pattern.compile("\\s*|\t|\r|\n");
		   Matcher m = p.matcher(str);
		   dest = m.replaceAll("");
		  }
		  return dest;
	 }


	public static String trimString(String text){
		return text.replace(" ","");
	}

}
